package com.bootdo.mall.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.bootdo.mall.dao.GoodSpecsDao;
import com.bootdo.mall.domain.GoodSpecs;
import com.bootdo.mall.service.GoodSpecsService;



@Service
public class GoodSpecsServiceImpl implements GoodSpecsService {
	@Autowired
	private GoodSpecsDao goodSpecsDao;
	
	@Override
	public GoodSpecs get(Long id){
		return goodSpecsDao.get(id);
	}
	
	@Override
	public List<GoodSpecs> list(Map<String, Object> map){
		return goodSpecsDao.list(map);
	}

	@Override
	public int addStock(Integer stock, Long id) {
		return goodSpecsDao.addStock(stock, id);
	}

	@Override
	public int delStock(Integer stock, Long id) {
		return goodSpecsDao.delStock(stock, id);
	}

	@Override
	public Long getSalesNumByGoodId(Long goodId) {
		return goodSpecsDao.getSalesNumByGoodId(goodId);
	}

	@Override
	public int count(Map<String, Object> map){
		return goodSpecsDao.count(map);
	}
	
	@Override
	public int save(GoodSpecs goodSpecs){
	
		if(goodSpecs.getId() != null) {
			return goodSpecsDao.update(goodSpecs);
		}else {
			return goodSpecsDao.save(goodSpecs);
		}		
	
		
	}
	
	@Override
	public int update(GoodSpecs goodSpecs){
		return goodSpecsDao.update(goodSpecs);
	}
	
	@Override
	public int remove(Long id){
		return goodSpecsDao.remove(id);
	}
	
	@Override
	public int batchRemove(Long[] ids){
		return goodSpecsDao.batchRemove(ids);
	}
	
}
